﻿
using HBase;
using System;
using System.Collections.Generic;
namespace hCommand {
    [Serializable]
    public class TaskCrane :BaseTask {
        public const int CENTER_DISTANCE = 6150;
        public static int getBaseDistance(Edge e) {//反射使用

            return e.b;
        }
        public byte forkNo {
            get; set;
        }
        public byte craneId {
            get; set;
        }



        public int sx {
            get; set;
        }
        public int sy {
            get; set;
        }
        public int sz {
            get; set;
        }

        public int dx {
            get; set;
        }
        public int dy {
            get; set;
        }
        public int dz {
            get; set;
        }
        public int priority { get; set; }
        public override List<string> getLableData() {
            List<String> list = new List<string>();
            list.Add("编号:" + src + "->" + des);
            list.Add("起点：x:" + sx + " y:" + sy + " z:" + sz);
            list.Add("终点：x:" + dx + " y:" + dy + " z:" + dz);
            list.Add(extra);
            return list;
        }
        public override void init(CoreTask complete ,CoreTaskParam param ,TaskDto taskDto) {
            src = taskDto.src;
            des = taskDto.des;
            extra = src + "-->" + des;

            taskNo = param.taskNo;
            code = complete.boxCode;
            completeId = complete.id;
            completeParamId = param.id;
            status = ( int ) CoreTaskParamStatus.待执行;
            CoreWhLoc StartPoint = MyCache.getValue<CoreWhLoc>(src);
            CoreWhLoc EndPoint = MyCache.getValue<CoreWhLoc>(des);
            ralyForbid = ralyForbid;
            waveNo = complete.waveNo;

            if( EndPoint == null ) {
                LoggerCommon.consoleOnly("垛机未找到终点位置:  " + des + " not find");
            } else {
                craneId = EndPoint.craneId;
                this.driveId = craneId;
                dx = EndPoint.x;
                dy = EndPoint.y;
                dz = EndPoint.z;

            }





            if( StartPoint == null ) {
                LoggerCommon.consoleOnly("垛机未找到起点 位置:crane Pos " + src + " not find");
            } else {
                craneId = StartPoint.craneId;
                this.driveId = craneId;
                sx = StartPoint.x;
                sy = StartPoint.y;
                sz = StartPoint.z;
            }



        }

    }
}
